package com.bootdo.program.wallpaper.controller;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.alipay.api.AlipayApiException;
import com.bootdo.program.wallpaper.domain.TzUserDO;
import com.bootdo.program.wallpaper.service.TzUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bootdo.program.wallpaper.domain.WithdrawalDetailsDO;
import com.bootdo.program.wallpaper.service.WithdrawalDetailsService;
import com.bootdo.common.utils.PageUtils;
import com.bootdo.common.utils.Query;
import com.bootdo.common.utils.R;

/**
 * 提现表
 * 
 * @author guoyunfei
 * @email 2549789059@qq.com
 * @date 2022-01-04 11:14:40
 */
 
@Controller
@RequestMapping("/wallpaper/withdrawalDetails")
public class WithdrawalDetailsController {
	@Autowired
	private WithdrawalDetailsService withdrawalDetailsService;


	
	@GetMapping()
	@RequiresPermissions("wallpaper:withdrawalDetails:withdrawalDetails")
	String WithdrawalDetails(){
	    return "wallpaper/withdrawalDetails/withdrawalDetails";
	}
	
	@ResponseBody
	@GetMapping("/list")
	@RequiresPermissions("wallpaper:withdrawalDetails:withdrawalDetails")
	public PageUtils list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);
		List<WithdrawalDetailsDO> withdrawalDetailsList = withdrawalDetailsService.list(query);
		int total = withdrawalDetailsService.count(query);
		PageUtils pageUtils = new PageUtils(withdrawalDetailsList, total);
		return pageUtils;
	}
	
	@GetMapping("/add")
	@RequiresPermissions("wallpaper:withdrawalDetails:add")
	String add(){
	    return "wallpaper/withdrawalDetails/add";
	}

	@GetMapping("/edit/{id}")
	@RequiresPermissions("wallpaper:withdrawalDetails:edit")
	String edit(@PathVariable("id") Long id,Model model,Integer status){
		WithdrawalDetailsDO withdrawalDetails = withdrawalDetailsService.getById(id);

		model.addAttribute("withdrawalDetails", withdrawalDetails);
		model.addAttribute("status", status);
	    return "wallpaper/withdrawalDetails/edit";
	}

	@GetMapping("/query/{id}")
	@RequiresPermissions("wallpaper:withdrawalDetails:edit")
	String query(@PathVariable("id") Long id,Model model){
		WithdrawalDetailsDO withdrawalDetails = withdrawalDetailsService.getById(id);

		model.addAttribute("withdrawalDetails", withdrawalDetails);
		return "wallpaper/withdrawalDetails/query";
	}
	
	/**
	 * 保存
	 */
	@ResponseBody
	@PostMapping("/save")
	@RequiresPermissions("wallpaper:withdrawalDetails:add")
	public R save( WithdrawalDetailsDO withdrawalDetails){
		if(withdrawalDetailsService.save(withdrawalDetails)>0){
			return R.ok();
		}
		return R.error();
	}
	/**
	 * 修改
	 */
	@ResponseBody
	@RequestMapping("/update")
	@RequiresPermissions("wallpaper:withdrawalDetails:edit")
	public R update( WithdrawalDetailsDO withdrawalDetails) throws AlipayApiException {

		int i = withdrawalDetailsService.updateTx(withdrawalDetails);
		if(i == 0){
			return R.error("操作失败");
		}

		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@PostMapping( "/remove")
	@ResponseBody
	@RequiresPermissions("wallpaper:withdrawalDetails:remove")
	public R remove( Long id){
		if(withdrawalDetailsService.remove(id)>0){
		return R.ok();
		}
		return R.error();
	}
	
	/**
	 * 删除
	 */
	@PostMapping( "/batchRemove")
	@ResponseBody
	@RequiresPermissions("wallpaper:withdrawalDetails:batchRemove")
	public R remove(@RequestParam("ids[]") Long[] ids){
		withdrawalDetailsService.batchRemove(ids);
		return R.ok();
	}
	
}
